package com.example.common.mapper;

import com.example.common.pojo.CompInfo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.Date;

@Mapper
@Component
@CacheNamespace(blocking = true)
public interface ICompInfoMapper {
    public String table = "company_information";
    @Select("select * from "+table+" where com_name=#{name}")
    CompInfo getCompInfoByName(String name);

    @Delete("delete from "+table+" where com_name=#{name}")
    int deleteCompInfo(String name);

    @Insert("insert into "+table+" values(null,#{comOrderamount},#{comShedTotalamount}," +
            "#{comWellPrice},#{comWellTotalamount},#{comDoorPrice},#{comDoorTotalamount}," +
            "#{comFencePrice},#{comFenceTotalamount},#{comPhonePrice},#{comPhoneTotalamount}," +
            "#{comTvPrice},#{comTvTotalamount},#{comName},#{comAdress},#{comProject},#{comNotetaker}," +
            "#{comSurveyor},#{comShedNum},#{comShedPrice},#{comWellNum},#{comDoorNum},#{comFenceNum}," +
            "#{comPhoneNum},#{comTvNum},#{comFillinPerson},#{comFillinDate},#{comOrder},#{comRelocatedPerson}," +
            "#{comBeRelocatedPerson},#{comTableNo},#{comMeasureDate})")
    int insertCompInfo(BigDecimal comOrderamount,BigDecimal comShedTotalamount,
                       BigDecimal comWellPrice, BigDecimal comWellTotalamount,
                       BigDecimal comDoorPrice,BigDecimal comDoorTotalamount,
                       BigDecimal comFencePrice,BigDecimal comFenceTotalamount,
                       BigDecimal comPhonePrice,BigDecimal comPhoneTotalamount,
                       BigDecimal comTvPrice,BigDecimal comTvTotalamount,String comName,
                       String comAdress,String comProject,String comNotetaker,
                       String comSurveyor,Integer comShedNum,BigDecimal comShedPrice,
                       Integer comWellNum,Integer comDoorNum,Integer comFenceNum,
                       Integer comPhoneNum,Integer comTvNum,String comFillinPerson,
                       Date comFillinDate,String comOrder,String comRelocatedPerson,
                       String comBeRelocatedPerson,String comTableNo,Date comMeasureDate);

    @Update("update "+table+" set com_orderamount = #{comOrderamount}," +
            "com_shed_totalamount=#{comShedTotalamount}," +
            "com_well_price=#{comWellPrice},com_well_totalamount=#{comWellTotalamount}," +
            "com_door_price=#{comDoorPrice},com_door_totalamount=#{comDoorTotalamount}," +
            "com_fence_price=#{comFencePrice},com_fence_totalamount=#{comFenceTotalamount}," +
            "com_phone_price=#{comPhonePrice},com_phone_totalamount=#{comPhoneTotalamount}," +
            "com_tv_price=#{comTvPrice},com_tv_totalamount=#{comTvTotalamount}," +
            "com_adress=#{comAdress},com_project=#{comProject},com_notetaker=#{comNotetaker}," +
            "com_surveyor=#{comSurveyor},com_shed_num=#{comShedNum},com_shed_price=#{comShedPrice}," +
            "com_well_num=#{comWellNum},com_door_num=#{comDoorNum},com_fence_num=#{comFenceNum}," +
            "com_phone_num=#{comPhoneNum},com_tv_num=#{comTvNum},com_fillin_person=#{comFillinPerson}," +
            "com_fillin_date=#{comFillinDate},com_order=#{comOrder},com_relocated_person=#{comRelocatedPerson}," +
            "com_be_relocated_person=#{comBeRelocatedPerson},com_table_no=#{comTableNo},com_measure_date=#{comMeasureDate} " +
            "where com_name=#{comName}")
    int updateCompinfo(BigDecimal comOrderamount,BigDecimal comShedTotalamount,
                       BigDecimal comWellPrice, BigDecimal comWellTotalamount,
                       BigDecimal comDoorPrice,BigDecimal comDoorTotalamount,
                       BigDecimal comFencePrice,BigDecimal comFenceTotalamount,
                       BigDecimal comPhonePrice,BigDecimal comPhoneTotalamount,
                       BigDecimal comTvPrice,BigDecimal comTvTotalamount,String comName,
                       String comAdress,String comProject,String comNotetaker,
                       String comSurveyor,Integer comShedNum,BigDecimal comShedPrice,
                       Integer comWellNum,Integer comDoorNum,Integer comFenceNum,
                       Integer comPhoneNum,Integer comTvNum,String comFillinPerson,
                       Date comFillinDate,String comOrder,String comRelocatedPerson,
                       String comBeRelocatedPerson,String comTableNo,Date comMeasureDate);


}
